$.ajaxSetup({ //设置全局性的Ajax选项
	error: function (msg) {
		console.log(msg);
		if(msg.status == 417){
			alert(msg.responseText);
		}
		if(msg.status == 200){
			alert('数据错误，请联系管理员！');
		}
		if(msg.status == 401){
			location.href = msg.responseText;
		}
		if(msg.status == 203){
			location.href = msg.responseText;
		}
	}
});

//格式化日期
Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

//格式化小数
Number.prototype.Format = function (n) {
	if(typeof(n) != "number"){
		n = 2;
	}
	var num = String(this);
	if(num.indexOf(".") > -1){
		num += "00000000001";
	}else{
		num += ".000000000011";
	}
	return Number(num).toFixed(n);
}

//字符串替换占位符
String.prototype.format=function()  {  
  if(arguments.length==0) return this;  
  for(var s=this, i=0; i<arguments.length; i++)  
    s=s.replace(new RegExp("\\{"+i+"\\}","g"), arguments[i]);  
  return s;  
};  

//判断元素在数组内的位置
if (!Array.indexOf) {
	Array.prototype.indexOf = function (obj) {  
	    for (var i = 0; i < this.length; i++) {  
	        if (this[i] == obj) {  
	            return i;  
	        }  
	    }  
	    return -1;  
	}
}
function getNowFormatDate() {
    var date = new Date();
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = year + seperator1 + month + seperator1 + strDate;
    return currentdate;
}
function toThousands(num) {
	var num = (num || 0).toString(), result = '';
    var nums = ["", ""];
	var flg = false;
	if(num.indexOf("-") > -1){
		num = num.substr(1);
		flg = true;
	}
    if(num.indexOf('.') > -1){
    	nums = num.split('.');
    	num = nums[0];
    	nums[1] = "." + nums[1];
    }
    while (num.length > 3) {
        result = ',' + num.slice(-3) + result;
        num = num.slice(0, num.length - 3);
    }
    if (num) { result = num + result; }
    return (flg?"-":"") + result + nums[1];
}

//获取json数组的长度
function getJsonLenth(json){
	var num = 0;
	try {
		for(var i in json){
			num++;
		}
	} catch (e) {
		console.error(e);
	}
	return num;
}

//设置cookie
function setCookie(name,value,Days) { 
	Days = Days || 30;
    var exp = new Date(); 
    exp.setTime(exp.getTime() + Days*24*60*60*1000); 
    document.cookie = "{0}={1};expires={2};path=/".format(name, escape (value), exp.toGMTString());
} 

//读取cookies 
function getCookie(name) { 
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg))
        return unescape(arr[2]); 
    else 
        return null; 
}

var excelPath = "/pms/excel/export.do";

$(function(){
$('.iframe').css('height', "calc( 100vh - 183px)");
	
//绑定全屏事件
$('.result-box').on('click', '#fullscreen', requestFullScreen);
function requestFullScreen() {
	var element = document.getElementsByClassName('result-box')[0];
	var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
	
	if (isFullscreenForNoScroll()) {
		if (requestMethod) {      
			document.exitFullscreen?document.exitFullscreen():
			document.webkitExitFullscreen?document.webkitExitFullscreen():
			document.mozCancelFullScreen?document.mozCancelFullScreen():
			document.msExitFullscreen?document.msExitFullscreen():'';
	  }else if (typeof window.ActiveXObject !== "undefined") {      
	    var wscript = new ActiveXObject("WScript.Shell");    
	    if (wscript !== null) {    
	      wscript.SendKeys("{F11}");    
	    }    
	  }
	}else {
		if (requestMethod) {      
	    requestMethod.call(element);
	  }else if (typeof window.ActiveXObject !== "undefined") {      
	    var wscript = new ActiveXObject("WScript.Shell");    
	    if (wscript !== null) {    
	      wscript.SendKeys("{F11}");    
	    }    
	  }
	}
}
//判断是否全屏
function isFullscreenForNoScroll(){
  var explorer = window.navigator.userAgent.toLowerCase();
  if(explorer.indexOf('chrome')>0){//webkit
    if (document.body.scrollHeight === 0) {
      return true;
    } else {
    	return false;
    }
  }else{//IE 9+  fireFox
    if (window.outerHeight === 0) {
    	return true;
    } else {
    	return false;
    }
  }
}
});



var echartsTheme = {
	color: ['#ffd755','#ffa34a','#64caf5','#b98fec','#a3d62c','#ff8da9','#673a79','#00acc1','#ed6f70','#2e8bca']
};

